  <style>
.catscroll{
    height:200px;
    overflow:scroll;
    width:310px;
    border:1px solid #ddd;
}
.catscroll p{margin:1px;}
</style>
 <?php
 if($dulieu){
    $idnet=$dulieu->idnet;    
 }else $idnet=0;
 $country = $this->Admin_model->get_data('country',array('show'=>1));
 //$type = $this->Admin_model->get_data('offer_type',array('publish'=>1));

 ?>

<form class="clearfix" method="POST" action="<?php echo base_url().'admin/route/'.$this->uri->segment(3);?>/list">

 <?php if($dulieu){echo '<input class="hide" value="'.$dulieu->id.'" name="id"/>';} ?>

                    <table class="tb_content clearfix">                       

                        <tr>

                            <td class="span200" >Title</td>

                            <td>

                                <input value="<?php if($dulieu){echo $dulieu->title;} ?>" class="span300" type="text" name="title" />

                            </td>

                            

                        </tr>  

                        

                        <tr>

                            <td>Network</td>

                            <td class="idnet_c">

                                <select name="idnet">

                                    <?php if($category){

                                        foreach ($category as $category){

                                            echo '<option value="'.$category->id.'">'.$category->title.'</option>';

                                        }                                        

                                    }?>

                                </select>                                

                            </td>                            

                        </tr> 

                        <tr>
                            <td>Country</td>
                            <td class="idnet_c">
                            <!-- chon ca list country-->
                                <div class="catscroll"> 
                                <?php
                                 if(!empty($dulieu)){$mangnsx=explode('o',$dulieu->country);}
                                    if(!empty($country)){
                                        foreach ($country as $country){
                                            echo '
                                            <p><input type="checkbox" size="40" value="'.$country->code.'" name="country[]" ';
                                            if(!empty($mangnsx)){
                                                if(in_array($country->code,$mangnsx)){
                                                     echo ' checked'; 
                                                 }
                                            }
                                            
                                            echo '
                                            />
                                            '.$country->country.'</p>
                                            ';
                                        }
                                    }
                                ?>
                                    
                                </div>
                            <!-- end chon ca list country-->
                                                             
                            </td>                            
                        </tr>

                        <tr>

                            <td>Point</td>

                            <td>

                                <input id="point" class="span100" value="<?php if($dulieu){echo $dulieu->point;} ?>" type="text" name="point" />

                                <span id="pointrate"><?php if($dulieu){echo '$ '.$dulieu->point*$dulieu->rate.' Point';} ?></span>

                            </td>                            

                        </tr>

                        

                         <tr>

                            <td>Link</td>

                            <td>

                                <input value="<?php if($dulieu){echo $dulieu->url;} ?>" class="span300" type="text" name="url" />

                            </td>                            

                        </tr>

                        

                        <tr>

                            <td>Images</td>

                            <td>

                                <input type="text" id="xFilePath" name="img" style="width:300px" value="<?php if($dulieu){echo $dulieu->img;} ?>"/>

                                <input type="button" value="Upload" onclick="BrowseServer();" />

                            </td>                            

                        </tr>

                        

                        <tr>

                            <td>Description</td>

                            <td>

                                <textarea class="span300" name="description"><?php if($dulieu){echo $dulieu->description;} ?></textarea>

                            </td>                            

                        </tr> 

                        

                        <tr>

                            <td>Order</td>

                            <td>

                                <input value="<?php if($dulieu){echo $dulieu->order;} ?>" class="span100" type="text" name="order" />

                            </td>                            

                        </tr>

                        

                        <tr>

                            <td>Show / Hide</td>

                            <td>

                                <span class="box_switch<?php if($dulieu){echo $dulieu->show==1? '':' off';} ?>">

                                    <a href="">switch off</a>

                                    <input id="off_on" type='hidden' name="show" value="1"/>

                                </span>                                

                            </td>                            

                        </tr> 

                        

                        <!-- phan co dinh-->

                        

                       <tr><td colspan="2" class="submit_td"><input type="submit" value="Submit" /></td></tr> 

                    </table>

                    <script type="text/javascript" src="<?php echo base_url();?>temp/admin/js/network_edit.js"></script>  

                

</form>

<script>

$(document).ready(function(){

    var id = $('.idnet_c select').val();

    getlinkpb(id);

    $('.idnet_c').change(function(){

    id = $('.idnet_c select').val();

    getlinkpb(id);

    }); 

  ratepoint();  

$('#point').on('keyup', function(){

             

        ratepoint();

    });        



});

function ratepoint(){

    value = $('#point').val();   

        var diachi = '<?php echo base_url()."admin/ajax/point_off/";?>';

        $.ajax({

            type:"POST",

            url:diachi,

            data:{data:value},

            success:callb,

            error:err        

        });

}

function getlinkpb(id){

    var diachi = '<?php echo base_url()."admin/ajax/get_net/";?>'+id;

    $.ajax({

            type:"POST",

            url:diachi,

            data:{data:id},

            success:callback,

            error:err        

        });    

}

function callback(data, status){

    $(".posbacklink").html(data);

}

function callb(data, status){

    $('#pointrate').html(data);

}



</script>



